package main

import "fmt"
import "strings"

func main() {
	var index int
	var str string

	// 求最后出现字符串的索引
	index = strings.LastIndex("go golang", "go")
	fmt.Printf("index=%v\n", index)

	// 替换字符串中的子串
	str = strings.Replace("go go hello", "go", "go语言", 1)
	fmt.Printf("str=%v\n", str)

	// 按照某个字符，将字符串分割成字符串数组
	strArr := strings.Split("hello,world,ok", ",")
	fmt.Printf("strArr=%v\n", strArr)

	// 转大写
	str = "goLang Hello"
	str = strings.ToUpper(str)
	fmt.Printf("str=%v\n", str)

	// 将字符串左右两边的空格去掉
	str = strings.TrimSpace(" tn a lone gopher ntrn ")
	fmt.Printf("str=%v\n", str)

	// 指定去掉字符串左右两边的字符
	str = strings.Trim("! he!llo! ", " !")
	fmt.Printf("str=%q\n", str)

	// 判断是否以某字符串开头
	str = "hello"
	isPrefix := strings.HasPrefix(str, "he")
	fmt.Printf("isPrefix=%v\n", isPrefix)

}	
